<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<script>
	$(document).ready(function() {
		$('#simple-button').popover('#simple-popover', {});
		$('#top-button').popover('#top-popover', {
			preventLeft : true,
			preventRight : true,
			preventBottom : true
		});
	});
</script>
<style type="text/css">
.title1 {
	background-color: #EAEFF4;
	color: #006699;
	font-size: 14px;
	font-weight: bold;
	overflow: auto;
	padding: 2px 6px;
}
</style>
<table class="display" id="example">
	<thead>
		<tr>
			<th>培训课程</th>
			<th>开始日期</th>
			<th>结束日期</th>
			<th>培训对象</th>
			<th>培训类型</th>
			<th>地点</th>
			<th>讲师</th>
			<th>评价</th>
		</tr>
	</thead>
	<tbody>
		<s:if test="#request.plans==null || #request.plans.size<=0">
			<tr class="gradeA">
				<td colspan="8">暂无数据</td>
			</tr>
		</s:if>
		<s:else>
			<s:iterator var="plan" status="sta" value="#request.plans">
				<s:if test="#sta.even">
					<tr class="gradeA">
				</s:if>
				<s:else>
					<tr class="gradeC">
				</s:else>
				<td>${plan.title}</td>
				<td><fmt:formatDate value="${plan.planStartDate}"
						pattern="yyyy-MM-dd HH:mm" /></td>
				<td><fmt:formatDate value="${plan.planEndDate}"
						pattern="yyyy-MM-dd HH:mm" /></td>
				<td><span name="td_dutytarget" title="${plan.id}"></span></td>
				<td>${plan.category}</td>
				<td>${plan.classroom}</td>
				<td>${plan.trainLecturer.employeeinfoWork.baseId.name}</td>
				<td><a class="button" href="javascript:void(0)"
					onclick="showAssessContent(${plan.id},'心得报告')"><span
						style="background: url(${ctx}/images/img/report_magnify.png)"
						class="icon icon-ok">&nbsp;</span>查看</a></td>
				</tr>
			</s:iterator>
		</s:else>
	</tbody>
</table>
<p>
	<%@ include file="/WEB-INF/pages/common/main_orgtab_pager_train.jsp"%>
</p>
<div class="container_12 clearfix"
	style="margin-left: 0px; margin-right: 0px; width: 98%" id="assess_body" >
	<div class="tabs side grid_12">
		<h5>评价报告</h5>
		<ul class="clearfix" id="ul_tab">
			<li><a class="current" href="javascript:void(0)"
				onclick="tabChangeEvent(0)">心得报告</a></li>
			<li><a href="javascript:void(0)" onclick="tabChangeEvent(1)">教师自评</a></li>
			<li><a href="javascript:void(0)" onclick="tabChangeEvent(2)">HR评价</a></li>
			<!-- <li><a href="javascript:void(0)" onclick="tabChangeEvent(3)">课程资料下载</a></li> -->
		</ul>
		<section id="assess_body_content">
			<section style="display: block;" class="clearfix" title="心得报告">
				<div class="grid_12 alpha" id="assess_list_content_0">
				</div>
			</section>
			<section style="display: none;" class="clearfix" title="教师自评">
				<div class="grid_12 alpha" id="assess_list_content_1">
				</div>
			</section>
			<section style="display: none;" class="clearfix" title="HR评价">
				<div class="grid_12 alpha" id="assess_list_content_2">
				</div>
			</section>
		</section>
	</div>
</div>

<script type="text/javascript">
	$(document).ready(function(){
		$("#assess_body").attr("style","display:none");
		$("span[name='td_dutytarget']").each(function(i) {
			loadDutyTarget(this, $(this).attr("title"));
		});
	});
	
	function loadDutyTarget(obj, planId) {
		$.ajax({
			type : "get",
			url : "/ajax/query_dutytarget.xhtml?planId=" + planId,
			//data: "name=John&location=Boston",
			dataType : "html",
			success : function(data) {
				if (data != null) {
					$(obj).html(data);
				}
			}
		});
	}
	
	var  currentPlanId = 0;
	//显示评论列表 
	function showAssessContent(planId, weightTitle) {
		$("#assess_body").attr("style","display:block");
		currentPlanId = planId;
		loadAssessContent(planId,weightTitle,0);
	}

	function tabChangeEvent(idx) {
		$("#ul_tab li a").removeClass("current");
		$("#ul_tab").find("li").each(function(i) {
			if (idx == i) {
				$(this).find("a").addClass("current");
			}
		});
		
		var wtitle = "";
		$("#assess_body_content section").attr("style","display:none");
		$("#assess_body_content").find("section").each(function(i) {
			if (idx == i) {
				$(this).attr("style","display:block");
				wtitle = $(this).attr("title");
			}
		});

		loadAssessContent(currentPlanId,wtitle,idx);
	}
	
	function loadAssessContent(planId,weightTitle,tabIdx){
		var url = "/train/train_assess_employee.xhtml";
		var data = {"planId":planId, "weightTitle":weightTitle};
        //refreshListContent(url, data);
        $.ajax(url, {
            type:"POST",
            //data:{"organizationId":organizationId},
            data:data,
            dataType:"html",
            cache:false,
            success:function (a) {
                var obj = $("#assess_list_content_" + tabIdx);
                obj.html("");
                obj.append(a);
            },
            complete:function () {
            }
        });
	}

	
</script>